// pages/home_center/common_panel/components/Integer/index.js
Component({
  options: {
    styleIsolation: 'shared',
  },
  /**
   * 组件的属性列表
   */
  properties: {
    step: Number,
    scale: Number,
    min: Number,
    max: Number,
    unit: String,
    value: Number,
    dpName: String,
    dpCode: String,
  },

  /**
   * 组件的初始数据
   */
  data: {
    min: 1,
    step: 1,
    max: 1,
    scale: 0,
    unit: '%',
  },

  lifetimes: {
    attached: function () {
      const {
        step = 1,
        min = 0,
        max = 255,
        unit = '',
        scale = 0,
      } = this.properties;
      this.setData({ step, min, max, unit, scale });
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange: function (event) {
      const { dpCode } = this.properties;
      console.log(dpCode)
      const value = event.detail;
      this.setData({[dpCode]:value})
      this.triggerEvent('sendDp', { dpCode, value });
    },
  },
});
